<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>게시판 글 수정</title>

<script language="javascript">

</script>	
</head>
<body>

<s:form name="writeform" action="qaEdit"  method="post" 
	enctype="multipart/form-data" onsubmit="return titleTest();" theme="simple">
	<s:hidden name="shop_qa.qa_seq"></s:hidden>	
	
<table border=0 cellpadding=3>
<tr>
	<td colspan=2 align=center><h2>[ 글수정 ]</h2></td>
</tr>
<tr>
	<td>제목</td>
	<td><s:textfield name="shop_qa.qa_title" id="qa_title"
			cssStyle="width:400px;" onblur="formCheck()" /></td>
</tr>
<tr>
	<td>내용</td> 
	<td>
		<s:textarea name="shop_qa.qa_contents" id="contents" cssStyle="width:400px;height:200px;resize:none;"></s:textarea>
	</td>
</tr>

<tr>
	<td colspan="2" align=center>
		<s:submit value="수정" />
	</td> 
</tr>
</table>
</s:form>
	<script type="text/javascript">
//글쓰기폼 확인
function formCheck() {		
		$.ajax({
		type:"post",
		url:"spamCheck.action",		
		data:{searchText : $('#qa_title').val()},
		success:function(json){
			if(json.spamCheck != 0){				
				alert("해당 제목에 금칙어가 포함되어 있습니다.");
				$('#formSubmit').attr('disabled',true);
			}
			else if(json.spamCheck == 0){				
				$('#formSubmit').attr('disabled',false);
				
			}
		}});
}

// 작성글 양식 확인	
function titleTest(){
	var title = document.getElementById('qa_title');
	var content = document.getElementById('qa_contents');
	
	if (title.value.length < 5) {
		alert("제목을 5자 이상 입력하세요.");
		title.focus();
		title.select();
		return false;
	}
	
	if (content.value.length < 10) {
		alert("내용을 10자 이상 입력하세요.");
		title.focus();
		title.select();
		return false;
	}		
	return true;	
}
 
</script>
</body>
</html>
